// 删除有序数组中的重复项
// nums = [0,0,1,1,1,2,2,3,3,4] =》[0,1,2,3,4]  输出5

/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  let len = nums.length
  let i = 0
  for (let j = 0; j < len; j++) {
    if (nums[i] !== nums[j]) {
      i++
      nums[i] = nums[j]
    }
  }
  return i + 1
}

console.log(removeDuplicates([1, 1, 2]));
